package mgslangpack;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;

public class SearchBooking
{
    public SearchBooking() throws Exception
    {
        final TextField tf1;
        Label l1,l9;
        Button b1,b2,b3;
        final JFrame jf;

        jf= new JFrame("Seach for Booked Dates");
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setSize(1000,1000);
        jf.setLayout(null);
        jf.setVisible(false);

        Container ctn=jf.getContentPane();
        ctn.setBackground(Color.LIGHT_GRAY);
        JLabel Pic;
        Pic=new JLabel(new ImageIcon("33333.jpg"));
        Pic.setBounds(10,40,1000,667);
        ctn.add(Pic);

        Font f1 = new Font("Times New roman",Font.BOLD,24);
        l9 = new Label("Enter Reff. number of booking you are looking for:");
        l9.setBounds(50,10,690,40);
        l9.setFont(f1);
        jf.add(l9);

        l1= new Label("Reff No:");
        l1.setBounds(50,250,100,30);
        l1.setFont(f1);
        jf.add(l1);
        tf1 = new TextField();
        tf1.setBounds(150,250,250,30);
        jf.add(tf1);

        final TextArea ta = new TextArea();
        ta.setBounds(450,100,300,400);
        ta.setEditable(false);
        ta.setBackground(Color.WHITE);
        jf.add(ta);

        b1 = new Button("Search");
        b1.setBounds(245,315,80,30);
        b1.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                try
                {
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    final Connection con =
                            DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");
                    String bd,ng,rn,irn;
                    irn=tf1.getText();
                    Statement st = con.createStatement();
                    ResultSet rs = st.executeQuery("Select * From Bookings");
                    while(rs.next())
                    {
                        bd = rs.getString(1);
                        ng = rs.getString(2);
                        rn = rs.getString(3);
                        if((rn.equals(irn)))
                        {
                            ta.append("\nBooked Date:\t"+bd+"\nNo. of guest:\t"+ng+"\nReff. No:\t\t"+rn+"\n\n");
                            ta.append(" ");
                        }
                    }
                }
                catch(Exception e1){System.out.println("ERROR="+e1);}
            }
        }
        );
        jf.add(b1);

        b2 = new Button("Back");
        b2.setBounds(80,650,80,30);
        b2.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e2)
            {
                try
                {
                    jf.hide();
                    MenuStaff m = new MenuStaff();
                }
                catch(Exception e3){}
            }
        }
        );
        jf.add(b2);

        b3 = new Button("Exit");
        b3.setBounds(600,650,80,30);
        b3.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e2)
            {
                try
                {
                    System.exit(0);
                }
                catch(Exception e3){}
            }
        }
        );
        jf.add(b3);
        jf.show();
    }
}
/******************************************************************************/